# -*- coding: utf8 -*-

"""bt_server URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin

from app.views.index import index_view
from app.views.direct_download import TorrentFileDownload, ResourceDownload
from app.views.client import WebSocketTokenView, NotifyClientDonwloadResourceView
from app.views.resource import ResourceStatusListView, ResourceStatusDetailView

# for webbt
from app.views.webbt import WebbtConfigerView


urlpatterns = [
    url(r'^admin/', admin.site.urls),

    url(r'^$', index_view, name='index'),

    # 资源状态
    url(r'^bt/resources$', ResourceStatusListView.as_view(), name='resource_list'),
    url(r'^bt/resources/(?P<pk>[0-9]+)$', ResourceStatusDetailView.as_view(), name='resource_detail'),

    # websocket token
    url(r'^bt/clients/websocket-token$', WebSocketTokenView.as_view(), name='websocket-token'),

    # 通知客户端下载资源
    url(r'^bt/clients/notify/resource-download$', NotifyClientDonwloadResourceView.as_view(), name='notify_client_donwload_resource'),

    # bt torrent 下载
    url(r'^bt/direct-download/torrent-files/(?P<category>[a-zA-Z\-\_0-9]+)/(?P<file_name>[a-zA-Z\-\_0-9\.]+)$', TorrentFileDownload.as_view(), name='torrent_files_direct_download'),
    url(r'^bt/direct-download/resources/(?P<category>[a-zA-Z\-\_0-9]+)/(?P<file_name>[a-zA-Z\-\_0-9\.]+)$', ResourceDownload.as_view(), name='resources_direct_download'),

    # -------------------- webbt --------------------
    url(r'^webbt/configer$', WebbtConfigerView.as_view(), name='webbt-configer'),
]
